// Whisper 支持的语言列表
// 基于官方文档: https://github.com/openai/whisper/blob/main/whisper/tokenizer.py#L79

export const WHISPER_LANGUAGES = {
  en: 'English',
  zh: '中文',
  de: 'Deutsch',
  es: 'Español',
  ru: 'Русский',
  ko: '한국어',
  fr: 'Français',
  ja: '日本語',
  pt: 'Português',
  tr: 'Türkçe',
  pl: 'Polski',
  ca: 'Català',
  nl: 'Nederlands',
  ar: 'العربية',
  sv: 'Svenska',
  it: 'Italiano',
  id: 'Indonesian',
  hi: 'हिन्दी',
  fi: 'Suomi',
  vi: 'Tiếng Việt',
  he: 'עברית',
  uk: 'Українська',
  el: 'Ελληνικά',
  ms: 'Bahasa Melayu',
  cs: 'Čeština',
  ro: 'Română',
  da: 'Dansk',
  hu: 'Magyar',
  ta: 'தமிழ்',
  no: 'Norsk',
  th: 'ไทย',
  ur: 'اردو',
  hr: 'Hrvatski',
  bg: 'Български',
  lt: 'Lietuvių',
  la: 'Latina',
  mi: 'Te Reo Māori',
  ml: 'മലയാളം',
  cy: 'Cymraeg',
  sk: 'Slovenčina',
  te: 'తెలుగు',
  fa: 'فارسی',
  lv: 'Latviešu',
  bn: 'বাংলা',
  sr: 'Српски',
  az: 'Azərbaycan',
  sl: 'Slovenščina',
  kn: 'ಕನ್ನಡ',
  et: 'Eesti',
  mk: 'Македонски',
  br: 'Brezhoneg',
  eu: 'Euskera',
  is: 'Íslenska',
  hy: 'Հայերեն',
  ne: 'नेपाली',
  mn: 'Монгол',
  bs: 'Bosanski',
  kk: 'Қазақша',
  sq: 'Shqip',
  sw: 'Kiswahili',
  gl: 'Galego',
  mr: 'मराठी',
  pa: 'ਪੰਜਾਬੀ',
  si: 'සිංහල',
  km: 'ខ្មែរ',
  sn: 'ChiShona',
  yo: 'Yorùbá',
  so: 'Soomaali',
  af: 'Afrikaans',
  oc: 'Occitan',
  ka: 'ქართული',
  be: 'Беларуская',
  tg: 'Тоҷикӣ',
  sd: 'سنڌي',
  gu: 'ગુજરાતી',
  am: 'አማርኛ',
  yi: 'ייִדיש',
  lo: 'ລາວ',
  uz: 'Oʻzbek',
  fo: 'Føroyskt',
  ht: 'Kreyòl Ayisyen',
  ps: 'پښتو',
  tk: 'Türkmen',
  nn: 'Nynorsk',
  mt: 'Malti',
  sa: 'संस्कृत',
  lb: 'Lëtzebuergesch',
  my: 'မြန်မာ',
  bo: 'བོད་སྐད',
  tl: 'Filipino',
  mg: 'Malagasy',
  as: 'অসমীয়া',
  tt: 'Татарча',
  haw: 'ʻŌlelo Hawaiʻi',
  ln: 'Lingála',
  ha: 'Hausa',
  ba: 'Башҡорт',
  jw: 'Basa Jawa',
  su: 'Basa Sunda',
} as const;

// 常用语言列表（用于UI显示）
export const COMMON_LANGUAGES = [
  { code: 'en', name: WHISPER_LANGUAGES.en },
  { code: 'zh', name: WHISPER_LANGUAGES.zh },
  { code: 'ja', name: WHISPER_LANGUAGES.ja },
  { code: 'ko', name: WHISPER_LANGUAGES.ko },
  { code: 'fr', name: WHISPER_LANGUAGES.fr },
  { code: 'es', name: WHISPER_LANGUAGES.es },
  { code: 'de', name: WHISPER_LANGUAGES.de },
  { code: 'ru', name: WHISPER_LANGUAGES.ru },
  { code: 'it', name: WHISPER_LANGUAGES.it },
  { code: 'pt', name: WHISPER_LANGUAGES.pt },
  { code: 'ar', name: WHISPER_LANGUAGES.ar },
  { code: 'hi', name: WHISPER_LANGUAGES.hi },
  { code: 'th', name: WHISPER_LANGUAGES.th },
  { code: 'vi', name: WHISPER_LANGUAGES.vi },
  { code: 'nl', name: WHISPER_LANGUAGES.nl },
  { code: 'sv', name: WHISPER_LANGUAGES.sv },
  { code: 'pl', name: WHISPER_LANGUAGES.pl },
  { code: 'tr', name: WHISPER_LANGUAGES.tr },
  { code: 'id', name: WHISPER_LANGUAGES.id },
  { code: 'fi', name: WHISPER_LANGUAGES.fi },
] as const;

// 获取支持的语言代码数组
export const getSupportedLanguageCodes = (): string[] => {
  return Object.keys(WHISPER_LANGUAGES);
};

// 验证语言代码是否被支持
export const isValidLanguageCode = (code: string): boolean => {
  return code in WHISPER_LANGUAGES;
};

// 获取语言显示名称
export const getLanguageName = (code: string): string => {
  return WHISPER_LANGUAGES[code as keyof typeof WHISPER_LANGUAGES] || 'Unknown';
};